package com.springboot.frame.backup;

import lombok.extern.slf4j.Slf4j;
import org.quartz.*;

import javax.sql.DataSource;

/**
 * @author madman 定时任务管理器 用的方法是quartz原生代码工具实现，并没有与spring无缝集成
 */
@Slf4j
public class BackUpDatabaseJob implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        log.info("执行数据库备份开始");
        BackUpProperties backUpProperties = (BackUpProperties) jobExecutionContext.getJobDetail().getJobDataMap().get("properties");
        DataSource dataSource = (DataSource) jobExecutionContext.getJobDetail().getJobDataMap().get("dataSource");
        BackUpTemplate backUpTemplate = new BackUpTemplate(backUpProperties,dataSource);
        backUpTemplate.export();
        log.info("执行数据库备份结束");
    }
}
